<?php
global $_RQ,$_AR;
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
$return=array();
$return['status2']=array(
	array('id'=>1,'title'=>'待发货'),
	array('id'=>2,'title'=>'待收货'),
	array('id'=>3,'title'=>'已完成'),
	array('id'=>4,'title'=>'已关闭'),
	array('id'=>5,'title'=>'申请维权'),
	array('id'=>6,'title'=>'已维权'),
);
if($_RQ['op']=='list'){
	$pindex = max(1, intval($_SESSION['page']));
	$psize = 15;
	$params=array('uniacid'=>$_SESSION['uniacid'],'buytype >'=>4);
    $orderby='createtime desc';
	$total='';
	$return['list']=pdo_getslice('jy_weishop_order',$params,array($pindex,$psize),$total,$fields,'',$orderby);
	foreach($return['list'] as &$v){
		$v['nickname']=pdo_getcolumn('core_members',array('id'=>$v['mid']),'nickname');
		$v['createtime']=date('Y-m-d H:i:s',$v['createtime']);
	}
	$htmls=array(
		'type'=>'list',
		'tabs'=>array(
			array('op'=>'list','title'=>'订单管理'),
		),
		'list'=>array('data'=>'list','edit'=>false,'list'=>array(
			array('name'=>'ordersn','title'=>'订单号','type'=>'string'),
			array('name'=>'nickname','title'=>'买家','type'=>'string'),
			array('name'=>'price','title'=>'金额','type'=>'string'),
			array('name'=>'status','title'=>'订单状态','type'=>'radio','options'=>'status'),
			array('name'=>'buytype','title'=>'订单类型','type'=>'radio','options'=>'buytype'),			
			array('name'=>'createtime','title'=>'下单时间','type'=>'string'),
			array('name'=>'ispay','title'=>'是否支付','type'=>'radio','options'=>'ispay'),			
		),
		'action'=>array(	
			array('type'=>'href','action'=>'detail','title'=>'订单详情'),
			
		),),
		
		'search'=>array(
			array('name'=>'order','width'=>15,'title'=>'订单号','type'=>'string'),
			array('name'=>'nickname','width'=>15,'title'=>'用户昵称','type'=>'string'),
			array('name'=>'status','width'=>15,'title'=>'订单状态','type'=>'select','options'=>'status2'),
		)
	);
	$return['status']=array('1'=>'待发货','2'=>'待收货','3'=>'已完成','4'=>'已关闭','5'=>'申请维权','6'=>'已维权');
	$return['ispay']=array('0'=>'未支付','1'=>'已支付');
	$return['buytype']=array('0'=>'普通','1'=>'多商户','2'=>'货到付款','3'=>'自提','4'=>'加星','5'=>'砍价','6'=>'拼团','7'=>'秒杀','8'=>'抽奖','9'=>'夺宝');
	$return['htmls']=$htmls;	
	exi($return);
	}
if($_RQ['op']=='del'){

	$id=intval($_RQ['id']);
	if($id){
		$this->model('order')->order_delete($id);
	}
	$del=trim($_RQ['del'],';');
	if($del){
		$del=explode(';',$del);
		foreach($del as $id){
			$id=intval($id);
			if($id){
				$this->model('order')->order_delete($id);
			}
		}
	}
	exi('删除成功！');
}
?>